package com.fsm.system.entity;

import com.alibaba.fastjson2.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.mybatisflex.annotation.*;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

import com.mybatisflex.core.keygen.KeyGenerators;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

/**
 *  菜单管理实体类。
 *
 * @author 翻山鸣
 * @since
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema(description = "菜单管理")
@Table("t_system_menu")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class TSystemMenu implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
    * 菜单id
    */
    @Id(keyType = KeyType.Generator, value = KeyGenerators.snowFlakeId)
    @Schema(description = "菜单id")
    private String id;

    /**
    * 菜单名称
    */
    @Column(value = "title")
    @Schema(description = "菜单名称")
    private String title;

    /**
    * 菜单路径
    */
    @Column(value = "path")
    @Schema(description = "菜单路径")
    private String path;
    /**
     * 菜单文件路径
     */
    @Column(value = "file_path")
    @Schema(description = "菜单文件路径")
    private String filePath;

    /**
    * 菜单标记
    */
    @Column(value = "icon")
    @Schema(description = "菜单标记")
    private String icon;

    /**
    * 父级id
    */
    @Column(value = "pid")
    @Schema(description = "父级id")
    private String pid;

    /**
    * 创建时间
    */
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Column(value = "create_time",onInsertValue = "now()")
    @Schema(description = "创建时间")
    private Date createTime;

    /**
    * 修改时间
    */
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Column(value = "update_time",onUpdateValue = "now()")
    @Schema(description = "修改时间")
    private Date updateTime;

    /**
    * 是否存在
    */
    @Column(value = "exist",onInsertValue = "1",isLogicDelete = true)
    @Schema(description = "是否存在")
    private Integer exist;

    @Column(ignore = true)
    @Schema(description = "页数")
    private Integer page;

    @Column(ignore = true)
    @Schema(description = "条数")
    private Integer limit;

    /**
     * 租户ID
     */
    @Column(value = "tenant_id",tenantId = true)
    @Schema(description = "租户ID")
    private String tenantId;

    @Column(ignore = true)
    @RelationOneToMany(selfField = "id",targetField = "pid",extraCondition =" 0 = 0 ")
    @Schema(description = "菜单子集")
    private List<TSystemMenu> children;
}
